﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace BoggleGUI
{
    /// <summary>
    /// Interaction logic for SummaryWindow.xaml
    /// </summary>
    public partial class SummaryWindow : Window
    {
        public SummaryWindow(string[] words)
        {
            InitializeComponent();

            PopulateLists(words);
        }

        private void PopulateLists(string[] words)
        {
            string[] legal1, legal2, common, illegal1, illegal2;

            char[] separators = new char[] { ' ' };

            // form each individual list
            legal1 = words[1].Split(separators, StringSplitOptions.RemoveEmptyEntries);
            legal2 = words[2].Split(separators, StringSplitOptions.RemoveEmptyEntries);
            common = words[3].Split(separators, StringSplitOptions.RemoveEmptyEntries);
            illegal1 = words[4].Split(separators, StringSplitOptions.RemoveEmptyEntries);
            illegal2 = words[5].Split(separators, StringSplitOptions.RemoveEmptyEntries);

            legal1List.Text = MakeListString(legal1);
            legal2List.Text = MakeListString(legal2);
            commonList.Text = MakeListString(common);
            illegal1List.Text = MakeListString(illegal1);
            illegal2List.Text = MakeListString(illegal2);
            
        }

        private string MakeListString(string[] words)
        {
            if (words.Length > 0)
            {
                string list = "";

                list += words[0];

                for (int i = 1; i < words.Length; i++)
                    list += ", " + words[i].Trim();

                return list;
            }

            else return "No Entries";            
        }
    }
}
